<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    var merge = function (nums1, m, nums2, n) {
        nums1 = nums1.slice(0, m);
        // for (let i = 0; i < n; i++) {
        //     nums1.push(nums2[i]);
        // }
        nums1.splice(m + 1, 0, nums2.slice(0, n))
        console.log(nums1, nums2, nums1.concat(nums2), nums1.sort());
        return nums1.concat(nums2).sort();
    };
    console.log(merge([1, 2, 3, 0, 0, 0], 3, [2, 5, 6], 3));
</script>

</html>